//
//  SinaWeiboController.m
//  ios_51job
//
//  Created by kai ren on 27/09/2011.
//  Copyright 2011 none. All rights reserved.
//

#import "SinaWeiboController.h"
#import "JSONKit.h"

@implementation SinaWeiboController

//Get catch path
- (NSString *)getCatchPath{
	NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	NSString *documentsDirectory = [paths objectAtIndex:0];
	
	return [NSString stringWithFormat:@"%@/%@", documentsDirectory, SINA_OAUTH_CACHE];
}

- (void)share{
	if ([OAuthInfo objectForKey:@"user_id"]) {
		NSMutableDictionary *files = [NSMutableDictionary dictionary];
		NSString *url = SinaShareUrl;
		
		QOauthKey *oauthKey = [[QOauthKey alloc] init];
		oauthKey.consumerKey = SinaAppKey;
		oauthKey.consumerSecret = SinaAppSecret;
		oauthKey.tokenKey = [OAuthInfo objectForKey:TOKEN_KEY];
		oauthKey.tokenSecret= [OAuthInfo objectForKey:TOKEN_SECRET];
		
		NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
		[parameters setObject:content forKey:@"status"];
		
		QWeiboRequest *request = [[QWeiboRequest alloc] init];
		[request asyncRequestWithUrl:url 
						  httpMethod:@"POST" 
							oauthKey:oauthKey 
						  parameters:parameters 
							   files:files 
							delegate:self];
		
		[request release];
		[oauthKey release];
	}	
}

#pragma mark -
#pragma mark NSURLConnection Delegate

/** Delegate: Call when finish loading **/
- (void)connectionDidFinishLoading:(NSURLConnection *)conn{
	//NSString *result = [[NSString alloc] initWithData:_data encoding:NSUTF8StringEncoding];
}

@end
